package org.NooLab.itexx.app.gui.handlers.keys;

import java.awt.Component;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JFrame;
import javax.swing.JPanel;

import org.NooLab.itexx.app.gui.definition.ITexxWindowGuiIntf;
import org.NooLab.itexx.app.gui.handlers.WindowAppearanceIntf;




public class ItexxGuiKeyListener  {

	WindowAppearanceIntf windowAppearance;
	private ITexxWindowGuiIntf windowGui;
	private JPanel basePanel;
	
	
	
	public ItexxGuiKeyListener( WindowAppearanceIntf wa ) {

		windowAppearance = wa ;
		
		windowGui = wa.getWindowGui() ;
		
		basePanel = windowGui.getTopPanel() ;
		

	}

	public int add( Component component, int id, final KeyHandlingCallbackIntf keyhandler ) {
		
		if (component==null){
			return -1;
		}
		component.addKeyListener( new KeyAdapter() {
														public void keyPressed(KeyEvent evt) {
															keyhandler.keyPressed(evt);
														}
													});
		keyhandler.setKeyListener( component.getKeyListeners()[ component.getKeyListeners().length-1 ] );		 
		
		return 0;
	}
	
}
